package com.me.TextMissed_a1;

import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class WidgetReceiver extends BroadcastReceiver {

    public static final String WIDGET_INTENT_SMS = "TextMissedWidgetIntentSMS";
    public static final String WIDGET_INTENT_CALL = "TextMissedWidgetIntentCALL";

    @Override
    public void onReceive(Context context, Intent intent) {
    	// TODO Auto-generated method stub

    	//Toast.makeText(context, "Test", Toast.LENGTH_SHORT);
    	//Log.d("TestReceiver", "TestReceiver: " + intent.getAction());

    	if(WIDGET_INTENT_SMS.equals(intent.getAction())) 
    	{
    		Log.d("TestReceiver", "go to intent");
    		//Toast.makeText(context, "Test", Toast.LENGTH_SHORT).show();
    		try
            {
                Intent intent1 = new Intent(Intent.ACTION_MAIN);
                intent1.addCategory(Intent.CATEGORY_LAUNCHER);
                intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
                intent1.setClassName("com.android.mms", "com.android.mms.ui.ConversationList");
                //intent1.setClassName("com.android.contacts", "com.android.contacts.RecentCallsListActivity");
                context.startActivity(intent1);
            }
            catch(ActivityNotFoundException e)
            {
               //handle except
            }
    	}

    	if(WIDGET_INTENT_CALL.equals(intent.getAction())) 
    	{
    		Log.d("TestReceiver", "go to intent");
    		//Toast.makeText(context, "Test", Toast.LENGTH_SHORT).show();
    		try
            {
                Intent intent1 = new Intent(Intent.ACTION_MAIN);
                intent1.addCategory(Intent.CATEGORY_LAUNCHER);
                intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
                //intent1.setClassName("com.android.mms", "com.android.mms.ui.ConversationList");
                intent1.setClassName("com.android.contacts", "com.android.contacts.RecentCallsListActivity");
                context.startActivity(intent1);
            }
            catch(ActivityNotFoundException e)
            {
               //handle except
            }
    	}
    }

  }
